/**
 * Title: Hyperbolic engine
 * Description: jFamilyTree Engine
 * Version: provider
 * Copyright: (c) 2001-2008
 * Terms of use:see license agreement at http://treebolic.sourceforge.net/en/license.htm
 * Author: Bernard Bou
 * Company: bsys
 * Update: Mon Mar 10 00:00:00 CEST 2008
 */
package jFamilyTree.model;

import java.awt.Color;
import java.awt.Image;
import java.util.ArrayList;
import java.util.List;

/**
 * Node
 * 
 * @author Bernard Bou
 */
class NodeData
{
	// D A T A

	// id
	/**
	 * Node id
	 */
	protected String theId;

	// node data
	/**
	 * Node label
	 */
	protected String theLabel;

	/**
	 * Node BDate
	 */
        protected String theBDate;

	/**
	 * Node content
	 */
	protected String theContent;

	/**
	 * Node URL link
	 */
	protected String theLink;

	/**
	 * Node link target frame
	 */
	protected String theTarget;

	/**
	 * Background color
	 */
	protected Color theBackColor;

	/**
	 * Foreground color
	 */
	protected Color theForeColor;

	/**
	 * Node image filename
	 */
	protected String theImageFile;

	// tree edge data
	/**
	 * Tree edge label
	 */
	protected String theEdgeLabel;

	/**
	 * Tree edge color
	 */
	protected Color theEdgeColor;

	/**
	 * Tree edge style
	 */
	protected Integer theEdgeStyle;

	/**
	 * Node image filename
	 */
	protected String theEdgeImageFile;

	// C O N S T R U C T O R

	/**
	 * Construct node
	 */
	public NodeData()
	{
		theId = null;
		theLabel = null;
                theBDate = null;
		theContent = null;
		theBackColor = null;
		theForeColor = null;
		theImageFile = null;
		theLink = null;
		theTarget = null;
		
		theEdgeLabel = null;
		theEdgeColor = null;
		theEdgeStyle = null;
		theEdgeImageFile = null;
	}

	// I D

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getId()
	 */
	public String getId()
	{
		return theId;
	}

	// A C C E S S

	// display
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString()
	{
		return theLabel;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getLabel()
	 */
	public String getLabel()
	{
		return theLabel;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getEdgeLabel()
	 */
	public String getEdgeLabel()
	{
		return theEdgeLabel;
	}


        public String getBDate()
	{
		return theBDate;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getContent()
	 */
	public String getContent()
	{
		return theContent;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getBackColor()
	 */
	public Color getBackColor()
	{
		return theBackColor;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getForeColor()
	 */
	public Color getForeColor()
	{
		return theForeColor;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getEdgeColor()
	 */
	public Color getEdgeColor()
	{
		return theEdgeColor;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getEdgeStyle()
	 */
	public Integer getEdgeStyle()
	{
		return theEdgeStyle;
	}

	// link
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getLink()
	 */
	public String getLink()
	{
		return theLink;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getTarget()
	 */
	public String getTarget()
	{
		return theTarget;
	}

	// image
	/**
	 * Get image file
	 * 
	 * @return image file
	 */
	public String getImageFile()
	{
		return theImageFile;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getEdgeImageFile()
	 */
	public String getEdgeImageFile()
	{
		return theEdgeImageFile;
	}
}

/**
 * XNodeData node
 * 
 * @author Bernard Bou
 */
class XNodeData extends NodeData
{
	// D A T A

	// location
	/**
	 * Node location
	 */
	private final Location theLocation;

	// images
	/**
	 * Node image
	 */
	private Image theImage;

	/**
	 * Tree edge image
	 */
	protected Image theEdgeImage;

	// weight
	/**
	 * Node weight
	 */
	private double theWeight;

	/**
	 * Children weight
	 */
	private double theChildrenWeight;

	/**
	 * Least weight
	 */
	private double theMinWeight;

	// mouting
	/**
	 * MountPoint
	 */
	protected MountPoint theMountPoint;

	// C O N S T R U C T O R

	/**
	 * Constructor
	 */
	protected XNodeData()
	{
		theLocation = new Location();
		theWeight = 0.;
		theImage = null;
		theEdgeImage = null;
		theMountPoint = null;
	}

	// A C C E S S

	// location
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getLocation()
	 */
	public Location getLocation()
	{
		return theLocation;
	}

	// weight
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getWeight()
	 */
	public double getWeight()
	{
		return theWeight;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setWeight(double)
	 */
	public void setWeight(double thisWeight)
	{
		theWeight = thisWeight;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getChildrenWeight()
	 */
	public double getChildrenWeight()
	{
		return theChildrenWeight;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setChildrenWeight(double)
	 */
	public void setChildrenWeight(double thisWeight)
	{
		theChildrenWeight = thisWeight;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getMinWeight()
	 */
	public double getMinWeight()
	{
		return theMinWeight;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setMinWeight(double)
	 */
	public void setMinWeight(double thisWeight)
	{
		theMinWeight = thisWeight;
	}

	// mountpoint
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getMountPoint()
	 */
	public MountPoint getMountPoint()
	{
		return theMountPoint;
	}

	/**
	 * Set mountpoint
	 * 
	 * @param thisMountPoint
	 */
	public void setMountPoint(MountPoint thisMountPoint)
	{
		theMountPoint = thisMountPoint;
	}

	// images
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getImage()
	 */
	public Image getImage()
	{
		return theImage;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setImage()
	 */
	public void setImage(Image thisImage)
	{
		theImage = thisImage;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getEdgeImage()
	 */
	public Image getEdgeImage()
	{
		return theEdgeImage;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setEdgeImage(java.awt.Image)
	 */
	public void setEdgeImage(Image thisImage)
	{
		theEdgeImage = thisImage;
	}
}

/**
 * Node implementation
 * 
 * @author Bernard Bou
 */
public class Node extends XNodeData implements INode
{
	// D A T A

	/**
	 * Node children
	 */
	protected List<INode> theChildren;

	/**
	 * Parent node
	 */
	protected INode theParent;

	// C O N S T R U C T O R

	/**
	 * Construct node
	 * 
	 * @param thisParent
	 *        parent node
	 * @param thisId
	 *        node id
	 */
	public Node(INode thisParent, String thisId)
	{
		super();
		theParent = thisParent;
		if (thisParent != null)
			thisParent.getChildren().add(this);
		theChildren = new ArrayList<INode>();

		theId = thisId;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#getParent()
	 */
	public INode getParent()
	{
		return theParent;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#setParent(jFamilyTree.model.INode)
	 */
	public void setParent(INode thisParent)
	{
		theParent = thisParent;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jFamilyTree.model.INode#removeTChild(jFamilyTree.model.INode)
	 */
	public List<INode> getChildren()
	{
		return theChildren;
	}
}
